z=input()
x=[]
c=[]
for i in range(1, 4+1):
    x+=[int(z[:i])]
for i in range(2, 4+1):
    x+=[int(z[1:i])]
for i in range(3,4+1):
    x+=[int(z[2:i])]
for j in x:
    k=0
    for i in range(2,int(int(j)**0.5)+1):
        if int(j)%1==0 or int(j)==1:
            k+=1
        if k>0:c+=[0]
        else: c+=[int(j)]

print(max(c))
